<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>阶乘</title>
  <script>
    //利用递归函数求1~n的阶乘
    function fn(n) {
      if (n === 1){
        return 1;
      }
      return n * fn(n-1);
    }

    console.log(fn(4));
  </script>
</head>
<body>

</body>
</html>